<?php
@$addType = $_REQUEST['addType'];

include 'header.php';
?>
   		<div class='container'>
   			<div class='row'>
   				<div class='col-xs-2'>
   					<?php if($addType == "worker"){?>
   						<a href='workerList.php?type=worker' class='btn btn-default btn-block'>职员列表</a>
   					<?php }else if($addType == "role"){?>
   						<a href='workerList.php?type=role' class='btn btn-default btn-block'>职位列表</a>
   					<?php }else{?>
	   					<a href='index.php' class='btn btn-default btn-block'>返回首页</a>
	   					<a href='goodsList.php' class='btn btn-default btn-block'>商品列表</a>
	   					<a href='typeList.php' class='btn btn-default btn-block'>类型列表</a>
   					<?php }?>
   					<?php if($addType == "goods"){?>
   						<a href='addGoodsType.php?addType=type' class='btn btn-default btn-block'>添加商品类型</a>
   					<?php }else if($addType == "type"){?>
   						<a href='addGoodsType.php?addType=goods' class='btn btn-default btn-block'>添加商品</a>
   					<?php }?>
   				</div>
   				<?php if($addType == "goods"){?>
   					<div class='col-xs-8'>
   				<?php }else if($addType == "type" || $addType == "role"){?>
   					<div class='col-xs-4'>
   				<?php }else{?>
   					<div class='col-xs-8'>
   				<?php }?>
   					<div class='panel panel-primary'>
   						<div class='panel-heading'>
   							<?php if($addType == "goods"){?>
   								<div class='panel-title'>添加商品</div>
   							<?php }else if($addType == "type"){?>
		   						<div class='panel-title'>添加类型</div>
		   					<?php }else if($addType == "worker"){?>
		   						<div class='panel-title'>添加职员</div>
		   					<?php }else if($addType == "role"){?>
		   						<div class='panel-title'>添加职位</div>
		   					<?php }?>
   						</div>
   						<form class='form-horizontal' action='addPro.php' method='post' enctype='multipart/form-data'>
   							<?php if($addType == "goods"){?>
   								<input type='hidden' value='goods' name='addType' />
   							<?php }else if($addType == "type"){?>
		   						<input type='hidden' value='type' name='addType' />
		   					<?php }else if($addType == "worker"){?>
		   						<input type='hidden' value='worker' name='addType' />
		   					<?php }else if($addType == "role"){?>
		   						<input type='hidden' value='role' name='addType' />
		   					<?php }?>
	   						<div class='panel-body'>
	   							<?php if(!empty($mes)){?>
   									<div class='alert alert-danger'>
   										<?php @print($mes);?>
   										<div class='close' data-dismiss='alert'>&times;</div>
   									</div>
	   							<?php }?>
	   							<?php if($addType == "goods"){?>
	   								<div class='row'>
	   									<div class='col-xs-4' style='margin-top:20px;'>
	   										<img src='img/default.jpg' class='addGoodsImg updateGoodsImg' />
			   								<div class='form-group addGoodsGroup'>
			   									<label class='col-xs-3 control-label' for='file'>图片</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='file' id='file' type='file' placeholder='商品图片' required='required' />
				   								</div>
			   								</div>
	   									</div>
	   									<div class='col-xs-8'>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='name'>名称</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='name' id='name' type='text' placeholder='商品名称' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='stockPrice'>采购价格</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='stockPrice' id='stockPrice' type='number' placeholder='采购价格' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='sellPrice'>销售价格</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='sellPrice' id='sellPrice' type='number' placeholder='销售价格' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='basicStatus'>基本状态</label>
				   								<div class='col-xs-9'>
				   									<select class='form-control' id='basicStatus' name='basicStatus'>
				   										<option value="正常">正常</option>
				   										<option value="停售">停售</option>
				   									</select>
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='sellStatus'>销售状态</label>
				   								<div class='col-xs-9'>
				   									<select class='form-control' id='sellStatus' name='sellStatus'>
				   										<option value="入库">入库</option>
				   										<option value="上架">上架</option>
				   										<option value="缺货">缺货</option>
				   										<option value="下架">下架</option>
				   									</select>
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='stock'>库存量</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='stock' id='stock' type='number' placeholder='库存量' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='typeId'>类型</label>
				   								<div class='col-xs-9'>
				   									<select class='form-control' id='typeId' name='typeId'>
				   										<?php foreach($types as $type){?>
				   											<option value="<?php echo $type['id'];?>"><?php echo $type['name'];?></option>
				   										<?php }?>
				   									</select>
				   								</div>
				   							</div>
				   						</div>
				   					</div>
		   						<?php }else if($addType == "type"){?>
		   							<div class='form-group'>
		   								<label class='col-xs-3 control-label' for='name'>名称</label>
		   								<div class='col-xs-9'>
		   									<input class='form-control' name='name' id='name' type='text' placeholder='商品类型名称' required='required' />
		   								</div>
		   							</div>
		   						<?php }else if($addType == "worker"){?>
		   							<div class='row'>
	   									<div class='col-xs-4' style='margin-top:20px;'>
	   										<img src='img/default.jpg' class='addGoodsImg updateGoodsImg' />
			   								<div class='form-group addGoodsGroup'>
			   									<label class='col-xs-3 control-label' for='file'>头像</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='file' id='file' type='file' placeholder='职员头像' required='required' />
				   								</div>
			   								</div>
	   									</div>
	   									<div class='col-xs-8'>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='name'>姓名</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='name' id='name' type='text' placeholder='姓名' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='age'>年龄</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='age' id='age' type='number' placeholder='年龄' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='sex'>性别</label>
				   								<div class='col-xs-9'>
				   									<select class='form-control' id='sex' name='sex'>
				   										<option value="男">男</option>
				   										<option value="女">女</option>
				   									</select>
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='idCard'>身份证</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='idCard' id='idCard' type='number' placeholder='身份证' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='phone'>电话</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='phone' id='phone' type='number' placeholder='电话' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='location'>住址</label>
				   								<div class='col-xs-9'>
				   									<input class='form-control' name='location' id='location' type='text' placeholder='住址' required='required' />
				   								</div>
				   							</div>
				   							<div class='form-group'>
				   								<label class='col-xs-3 control-label' for='roleId'>职位</label>
				   								<div class='col-xs-9'>
				   									<select class='form-control' id='roleId' name='roleId'>
				   										<?php @$roles = dbSelectAll('select id,name from role order by id asc');
				   											foreach($roles as $role){?>
				   											<option value="<?php echo $role['id'];?>"><?php echo $role['name'];?></option>
				   										<?php }?>
				   									</select>
				   								</div>
				   							</div>
				   						</div>
				   					</div>
		   						<?php }else if($addType == "role"){?>
		   							<div class='form-group'>
		   								<label class='col-xs-4 control-label' for='name'>职位名称</label>
		   								<div class='col-xs-8'>
		   									<input class='form-control' name='name' id='name' type='text' placeholder='职位名称' required='required' />
		   								</div>
		   							</div>
		   						<?php }?>
	   						</div>
	   						<div class='panel-footer' style='padding-left:<?php echo $addType=="goods"?'205':'130';?>px;'>
	   							<button class='btn btn-primary' type='submit'>添加</button>
	   							<?php if($addType == "goods"){?>
	   								<a href='goodsList.php' class='btn btn-default'>返回</a>
	   							<?php }else if($addType == "type"){?>
			   						<a href='typeList.php' class='btn btn-default'>返回</a>
			   					<?php }else if($addType == "worker"){?>
			   						<a href='workerList.php?type=worker' class='btn btn-default'>返回</a>
			   					<?php }else if($addType == "role"){?>
			   						<a href='workerList.php?type=role' class='btn btn-default'>返回</a>
			   					<?php }?>
	   						</div>
   						</form>
   					</div>
   				</div>
   			</div>
   		</div>
   		<script src='db/previewImg.js'></script>
   	</body>
</html>
